﻿using System;
using System.Data;

namespace MySqlQueryToolkit
{
    public class Repository
    {
        protected static T GetColumnValue<T>(IDataReader reader, string columnName, T defaultValue)
        {
            var ordinal = reader.GetOrdinal(columnName);
            if (!reader.IsDBNull(ordinal))
            {
                return (T)Convert.ChangeType(reader.GetValue(ordinal), typeof(T));
            }
            return defaultValue;
        }
    }
}
